<template>
    <div class="range-wrapper">
        <ul class="range-list">
            <li :class="selectedRange === 'day' && 'selected'"
                @click="$emit('update:selectedRange', 'day')">按天
            </li>
            <li :class="selectedRange === 'week' && 'selected'"
                @click="$emit('update:selectedRange', 'week')">按周
            </li>
            <li :class="selectedRange === 'month' && 'selected'"
                @click="$emit('update:selectedRange', 'month')">按月
            </li>
        </ul>
    </div>
</template>

<script lang="ts">
    import Vue from 'vue';
    import {Component, Prop} from 'vue-property-decorator';

    @Component
    export default class Range extends Vue {
        @Prop(String) selectedRange: string | undefined
    }
</script>

<style lang="scss" scoped>
    @import "~@/assets/style/helper.scss";

    .range-list {
        display: flex;
        box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);

        > li {
            font-size: 1.2em;
            padding-top: 5px;
            padding-bottom: 5px;
            width: 50%;
            line-height: 2em;
            color: $color-lightgray;
        }

        > li.selected {
            color: $color-orange;
            position: relative;

            &::after {
                content: '';
                position: absolute;
                width: 100%;
                height: 2px;
                background: $color-orange;
                left: 0;
                bottom: 0;
            }
        }
    }

</style>